﻿@model EFEntity.Esf
@{
    ViewData["Title"] = "right_list_information111";

}
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>编辑角色</title>
        <script src="~/js/vue.js"></script>
        <script src="~/javascript/comm/comm.js"></script>
        <link rel="stylesheet" href="~/css/table.css" type="text/css" />
        <link href="~/animate.css" rel="stylesheet" />

        <script src="~/JSs/jquery-1.11.1.js"></script>
        <script src="~/jquery.validate.js"></script>
        <script src="~/JSs/jquery-easyui-1.3.5/jquery.easyui.min.js"></script>
        <link href="~/JSs/jquery-easyui-1.3.5/themes/bootstrap/easyui.css" rel="stylesheet" />
        <link href="~/JSs/jquery-easyui-1.3.5/themes/icon.css" rel="stylesheet" />
        <style type="text/css">
            .parent {
                margin-left: 50px;
            }

            .children {
                margin-left: 20%;
            }
        </style>

    </head>
    <body>
        <div id="tata">
            <form action="update1" method="post">
                <table width="100%">
                    <tr>
                        <td>
                            <font color="black">您正在做的业务是：人力资源--权限管理--编辑角色</font>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <input type="button" v-on:click="edit()" value="修改" />

                            <input type="button" value="返回" class="BUTTON_STYLE1"
                                   onclick="history.back()">
                            <input id="id" value="@ViewData["id"]" />
                            @*<input type="button" value="修改树状" id="update" />
                            <input type="submit" value="修改角色" id="update" />
                            <input type="button" value="返回" class="BUTTON_STYLE1"
                                   onclick="history.back()">*@
                        </td>
                    </tr>
                </table>
                <table width="100%" border="1" cellpadding=3 cellspacing=1
                       bordercolorlight=#848284 bordercolordark=#eeeeee
                       class="TABLE_STYLE1">
                    <tr>
                        <td class="TD_STYLE1">角色编号</td>
                        <td class="TD_STYLE2">
                            <input type="text" class="INPUT_STYLE2"
                                   asp-for="id" readonly="readonly" id="id" />
                        </td>
                        <td class="TD_STYLE1">角色名称</td>
                        <td class="TD_STYLE2">
                            <input type="text" class="INPUT_STYLE2"
                                   asp-for="user_sf" id="user_sf" />
                        </td>
                    </tr>
                    <tr>
                        <td class="TD_STYLE1">角色说明</td>
                        <td class="TD_STYLE2">
                            <input type="text" class="INPUT_STYLE2"
                                   asp-for="user_ms" id="user_ms" />
                        </td>
                        <td class="TD_STYLE1">角色是否可用</td>
                        <td class="TD_STYLE2">
                            <select asp-for="user_sfny" id="user_sfny">
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>

                        </td>
                    </tr>
                </table>
                <div>
                    @*树状图*@
                    <ul id="tt"></ul>
                </div>
            </form>

        </div>

    </body>
    <script type="text/javascript">

        var vm = new Vue({
            el: "#tata",
            data: {

            },
            methods: {
                load: function (id) {
                    var id = $("#id").val();
                    $("#tt").tree({
                        url: "/Power/Shu?idl=" + id,
                        checkbox: true,
                        onLoadSuccess: function (node, data) {
                            $(data).each(function (index, obj) {
                                if (obj.state == "closed") {
                                    $("#tt").tree('expandAll');
                                }
                            });
                        }
                    });
                },
                edit: function () {
                    var t = this;
                    var id = $("#id").val();
                    alert(1);
                    alert(id);
                    var user_sf = $("#user_sf").val();
                    var user_ms = $("#user_ms").val();
                    var user_sfny = $("#user_sfny").val();

                    if (id == "" || user_sf == "") {
                        alert("请完善所有信息再提交！");
                    } else {
                        t.Editquanxianjs();
                        //$.ajax({
                        //    url: "/Power/right_list_information",
                        //    type: "post",
                        //    data: { "id": id, "user_sf": user_sf, "user_ms": user_ms, "user_sfny": user_sfny },
                        //    success: function (msg) {

                        //        if (msg > 0) {
                        //            t.Editquanxianjs();
                        //        }
                        //    }
                        //});
                    }
                },
                Editquanxianjs: function () {
                    var t = this;
                    var s_id = $("#id").val();
                    //需求：获取全勾和半勾的id值
                    var ids = "";
                    var nodes = $('#tt').tree('getChecked');	// get checked nodes
                    console.info(nodes);
                    nodes.forEach(function (item) {
                        ids += item.id + ",";
                    });
                    var nodes2 = $('#tt').tree('getChecked', 'indeterminate');	// 获取不确定的节点
                    nodes2.forEach(function (item) {
                        ids += item.id + ",";
                    });
                    ids = ids.substr(0, ids.length - 1);

                    $.ajax({
                        url: "/Power/addquanxianjs",
                        type: "post",
                        data: {
                            "sid": t.id, "ids": ids
                        },
                        success: function (msg) {
                            alert(msg);
                            if (msg > 0 || msg == "" || msg == null) {
                                alert("操作成功");
                                t.load();
                                location.href = '/Power/right_list';
                            }
                        }
                    })
                    console.info(ids);
                },
            },

            mounted: function () {
                this.load();
            }
        });
    </script>
    </html>